﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XiaLastorm.Sharpshooter
{
	/// <summary>
	/// 错误消息
	/// </summary>
	[Serializable]
	public class ErrorMessage : Message
	{
		/// <summary>
		/// 错误信息
		/// </summary>
		public string Error { get; set; }

		/// <summary>
		/// 引起错误的消息
		/// </summary>
		public Message MessageToCauseError { get; set; }

		/// <summary>
		/// 生成 <see cref="ErrorMessage"/> class 的新实例。
		/// </summary>
		/// <param name="error">错误信息</param>
		/// <param name="messageToCauseError">引起错误的消息</param>
		public ErrorMessage(string error, Message messageToCauseError)
		{
			if (error == null)
				throw new ArgumentNullException("error");
			if (error.Trim() == string.Empty)
				throw new ArgumentException("错误信息为空");
			Error = error;
			MessageToCauseError = messageToCauseError;
		}
		public override string ToString()
		{
			return string.Format("Error: {0} Cause: {1}", Error, MessageToCauseError as object ?? string.Empty);
		}
	}
}
